<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ include file="/jsp/common/taglib.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<title>新建${table.comment!}</title>
</head>
<body>
<div class="page-content">
	<div class="content-15">
		<div class="col-sm-12 header lighter no-padding-top">
			<h5 class="no-margin-top">新建${table.comment!}</h5>
		</div>
		<div class="row">
			<form class="form-horizontal" role="form" id="form${vo}">
				<#list table.fields as field>
				<div class="form-group">
					<label class="col-sm-2 control-label no-padding-right" for="${field.propertyName}"> <i style="color: red;">*</i> <#if field.comment??>${field.comment}<#else>${field.propertyName}</#if></label>
					<div class="col-sm-6">
						<#if field.type == 'date'>
						<input type="text" id="${field.propertyName}" name="${field.propertyName}" class="col-xs-10 col-sm-5" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})"/>
						<#elseif field.type == 'datetime' || field.type == 'timestamp'>
						<input type="text" id="${field.propertyName}" name="${field.propertyName}" class="col-xs-10 col-sm-5" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"/>
						<#else>
						<input type="text" id="${field.propertyName}" name="${field.propertyName}" class="col-xs-10 col-sm-5" <#if field.type?contains('(')> maxlength="${(field.type?replace(')',''))?split('(')[1]}"</#if>/>
						</#if>
						<span class="help-inline col-xs-12 col-sm-7">
							<span class="middle" style="color: red" id="${field.propertyName}_msg"></span>
						</span>
					</div>
				</div>
				</#list>
				<div class="col-xs-12">
					<div class="text-center form-actions">
						<button class="btn btn-info" id="${vo?uncap_first}SaveBut" type="button" onclick="add${vo}()">
							保存
						</button>
						<button class="btn btn-primary" type="button" onclick="reBackList();" >
							返回列表
						</button>
					</div>
				</div>
			</form>
		</div>
	</div>
</div>
</body>
<script type="text/javascript">
	// 创建资讯
	function add${vo}() {
		$("#${vo?uncap_first}SaveBut").attr("disabled",true);
		$.ajax({
			type : 'POST',
			dataType : 'text',
			url : "${r'$'}{ctx}<#if package.ModuleName??>/${package.ModuleName}</#if>/<#if controllerMappingHyphenStyle??>${controllerMappingHyphen}<#else>${table.voPath}</#if>/save.action",
			data : ${r'$'}("#form${vo}").serialize(),
			success : function(rs) {
				if (rs != "") {
                    loadOther("${r'$'}{ctx}<#if package.ModuleName??>/${package.ModuleName}</#if>/<#if controllerMappingHyphenStyle??>${controllerMappingHyphen}<#else>${table.voPath}</#if>/view.action?<#list table.fields as field><#if field.keyFlag>${field.propertyName}</#if></#list>="+rs);
				} else {
					bootbox.alert("操作失败!");
				}
			},
			error : function() {
				bootbox.alert("操作失败!");
			}, complete : function () {
				$("#${vo?uncap_first}SaveBut").removeAttr("disabled");
			}
		});
	}

	function reBackList(){
		loadOther("${r'$'}{ctx}<#if package.ModuleName??>/${package.ModuleName}</#if>/<#if controllerMappingHyphenStyle??>${controllerMappingHyphen}<#else>${table.voPath}</#if>/index.action?isCacheSearchParams=true");
	}
</script>
</html>